var GdgsIcon={
	iconDefaultSize: 64,
	cacheData: {},
	generateIconXY: function($icon, times, data){
		var left = $icon.css("background-position-x");
		var top = $icon.css("background-position-y");
		var index = left.indexOf("px");
		if(index > -1){
			left = parseInt(left.substring(0,index));
		}
		index = top.indexOf("px");
		if(index > -1){
			top = parseInt(top.substring(0,index));
		}
		left = parseInt(left/times) + "px";
		top = parseInt(top/times) + "px";
		if(!data){
			data = {};
		}
		data["background-position"] = left+" "+top;
		$icon.css(data);
	},
	generateIconWHXY: function($icon, width, height, times){
		var width2 = parseInt(width/times) + "px";
		var height2 = parseInt(height/times) + "px";
		this.generateIconXY($icon, times, {"background-size": width2 +" "+ height2});
	},
	generateIconSize: function($icon, iconSize, iconUrl){
		if(!iconSize || iconSize<=0){
			iconSize = $icon.width();
		}
		if(!iconUrl){
			iconUrl = $icon.css("background-image");
		}
		var i = iconUrl.indexOf("url(");
		if(i >= 0){
			iconUrl = iconUrl.substring(i+4, iconUrl.lastIndexOf(')'));
		}
		var times = parseFloat(this.iconDefaultSize/iconSize);
		var self = this;
		var cacheData = self.cacheData;
		var data = cacheData[iconUrl];
		if(data){
			self.generateIconWHXY($icon, data.width, data.height, times);
		}else{
			var imgObj = new Image();
			imgObj.onload = function(evt){
				var width = this.width;
				var height = this.height;
				self.generateIconWHXY($icon, width, height, times);
				cacheData[iconUrl]= {
						width: width,
						height: height
					};
				imgObj = null;
			};
			imgObj.src = iconUrl;
		}
	},
	setBackgroundImg:function($icon, iconSize, iconUrl){
        setTimeout(function(){
			$icon.css("background", iconUrl);
			GdgsIcon.generateIconSize($icon, iconSize, iconUrl);
		},0);
	}
};